import Vue from "vue";
import Vuex from "vuex";
import mainPage from "./modules/mainPage";
import oneMap from "./modules/oneMap";
import oneMapConfig from "./modules/oneMapConfig";
import appBuilder from "./modules/appBuilder";
import FeatureLayer from "@arcgis/core/layers/FeatureLayer";
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    peopleInfo: []
  },
  mutations: {
    SET_PeopleInfo(state, payload) {
      state.peopleInfo = payload
    }
  },
  actions: {
    ReloadPeopleInfo({
      state,
      commit,
      rootState
    }, resdata) {


      Vue.prototype.$commonLayers.peopleLayer
        .queryFeatures()
        .then((featureSet) => {
          console.log(featureSet)
          commit("SET_PeopleInfo", featureSet.features);


        })
        .catch((err) => console.log(err));

    }
  },
  modules: {
    mainPage,
    oneMap,
    oneMapConfig,
    appBuilder
  }
});